package com.ssy.lingxi.platform.manage.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.model.request.appversion.AppVersionAddReq;
import com.ssy.lingxi.platform.manage.model.request.appversion.AppVersionPageReq;
import com.ssy.lingxi.platform.manage.model.request.appversion.AppVersionUpdateReq;
import com.ssy.lingxi.platform.manage.model.request.common.CommonIdRequest;
import com.ssy.lingxi.platform.manage.model.response.AppVersionManagerRes;
import com.ssy.lingxi.platform.manage.service.IAppVersionManagerService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 平台后台-系统管理-APP版本管理相关接口
 * @author wyx
 * @version 2.0.0
 * @date 2021-11-12
 */
@RestController
@RequestMapping("/manage/app/version")
public class AppVersionManagerController {
    @Resource
    private IAppVersionManagerService appVersionManagerService;


    /**
     * 新增版本
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Wrapper<Void> add(@RequestBody @Valid AppVersionAddReq req) {
        return appVersionManagerService.add(req);
    }

    /**
     * 修改版本
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> update(@RequestBody @Valid AppVersionUpdateReq req) {
        return appVersionManagerService.update(req);
    }

    /**
     * 查看版本详情
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/find", method = RequestMethod.GET)
    public Wrapper<AppVersionManagerRes> find(@Valid CommonIdRequest req) {
        return appVersionManagerService.find(req);
    }

    /**
     * 分页查看版本列表
     * @param req 请求参数
     * @return 操作结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<AppVersionManagerRes>> page(@Valid AppVersionPageReq req) {
        return appVersionManagerService.page(req);
    }
}
